package com.ddone;

import com.ddone.interceptor.KafkaProducerInterceptor;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.kafka.core.KafkaTemplate;

/**
 * @author ddone
 * @date 2024/5/14-09:43
 */
@SpringBootApplication
public class ProducerApplication {

    @Resource
    KafkaTemplate<String,String> kafkaTemplate;

    @Resource
    KafkaProducerInterceptor kafkaProducerInterceptor;


    public static void main(String[] args) {
        SpringApplication.run(ProducerApplication.class, args);
    }

    @PostConstruct
    public void init()
    {
        kafkaTemplate.setProducerInterceptor(kafkaProducerInterceptor);
        System.out.println("----init success over,KafkaTemplate配置生产者拦截器kafkaProducerInterceptor");
    }

}
